﻿using DDD.Application;
using DotNetCore.CAP;
using GoodsModule.Domain.GoodsDomainEvents;
using GoodsModule.IntegrationEvents;
using Microsoft.Extensions.Logging;


namespace GoodsModule.Application.DomainEventsHandler
{
    internal class GoodsDeductStockFailDomainEventHandler(
        ICapPublisher publisher,
        ILogger<GoodsDeductStockFailDomainEvent> logger)
        : IDomainEventHandler<GoodsDeductStockFailDomainEvent>
    {
        public Task Handle(GoodsDeductStockFailDomainEvent @event, CancellationToken cancellationToken)
        {
            return publisher.PublishAsync(nameof(GoodsDeductStockFailIntegrationEvent), new GoodsDeductStockFailIntegrationEvent(@event.OrderId, @event.GoodsId));
        }
    }
}
